import { Vector2 } from "../util"

export enum ComponentType {
    Button = 1,
    Panel = 2,
    TextLabel = 3,
    Image = 4,
    Progress = 5,
    Model = 6,
    TabWidget = 8,
    TabPage = 9,
    Scroll = 10,
    Slider = 11,
    Input = 15,
    MiniMap = 16,
    SkillBtn = 17,
    BuffList = 18,
    BuffItem = 19,
    Equip = 20, //物品栏 背包栏
    Shop = 21, //商店
    Goods = 22,//商品
    RichText = 26,
    Setting = 27, //设置
    Chat = 32,  //聊天框
    Page = 33, //轮播图
    AudioSwitch = 34, //语音开关
    Animation = 38  //序列帧
}

export class Component {
    /**
     * 基础属性
     */
    //类型
    public type: number
    public uid: string
    //名称
    public name: string
    //是否拦截鼠标点击
    public swallow_touches = true
    //游戏中是否可见
    public visible = false
    //是否可以拖动
    public can_drag = true
    //控件适配 开关
    public open_adapter = true
    //控件适配 上下左右开关 上下左右距离
    //边框与父级距离 margin的算法
    //与坐标对应的 修改控件适配自动修改坐标
    public adapter_option: [
        boolean, boolean, boolean, boolean,
        number, number, number, number
    ]

    /**
     * 坐标和尺寸
     */
    //坐标位置 中心点相对父级的左下角
    //与控件适配对应 修改坐标自动修正控件适配
    public pos: Vector2
    //尺寸 默认100x100
    public size: Vector2
    //旋转 0~360 默认0
    public rotation = 0
    //xy轴缩放0~1 默认 11
    public scale: Vector2
    //透明度0~1 -> 0~100
    public opacity = 0.9
    //锚点0~1 默认0.5 0.5
    public anchor: Vector2


    //子节点
    public children: Array<Component> = []
    //动画 
    public comp_anims = []
    //事件
    public event_list = []

    //?
    public pos_percent: Vector2
}